import {useTableActionRedux} from "@/components/ant-ext-table/redux/HAdminContext";
import {useActionForm} from "@/common/hooks";
import HModal from "@/components/ant-ext/HModal";
import {Form} from "antd";
import HFormItem from "@/components/ant-ext/HFormItem";
import {WithdrawalStat} from "@/const/const";
import {SysAdminEntity} from "@/api/sys-admin";
import {useState} from "react";
import EntityWithdrawal from "@/api/entity-withdrawal";

export default function WithdrawalOpt() {
    const [loading, setLoading] = useState(false)
    const {action, reset} = useTableActionRedux<SysAdminEntity>()
    const {form, key, title} = useActionForm(action, [EntityWithdrawal.OPT], EntityWithdrawal.MAPPING)
    const close = () => {
        reset()
        form.resetFields()
    }
    console.log(key,title)


    return <>
        <HModal onCancel={close} type={"setUp"} width={500} onOk={form.submit}
                confirmLoading={loading}
                visible={title !== undefined}
                title={title}
        >

            <Form name={"editForm"} form={form} labelCol={{span: 5}}
                  onFinish={() => {
                      EntityWithdrawal.doExec({
                          body: form.getFieldsValue(), setLoading, success: () => {
                              close()
                          }
                      })
                  }}>
                <HFormItem label={"编号"} name={"id"} disabled/>
                <HFormItem label={"状态"} type={"radio"} dataSource={WithdrawalStat.select} name={"stat"}
                           required/>

            </Form>
        </HModal>
    </>
}